#!/usr/bin/env python

def init(ctx):
    pass

def options(opt):
    pass

def configure(conf):
    pass

def build(bld):
    uselib = ['TESTMAIN', 'DLIB', 'SOCKET', 'DDF', 'THREAD', 'EXTENSION', 'PROFILE_NULL', 'RESOURCE', 'SCRIPT', 'GRAPHICS_NULL', 'PLATFORM_NULL', 'LUA']
    exported_symbols = ['LiveUpdateExt', 'ResourceProviderFile']

    for thread_version in ['multi', 'single']:
        for impl in ('', 'null'):
            local_lib = 'liveupdate'
            suffix = '_%s' % thread_version
            features = []
            defines = []

            if impl == 'null':
                local_lib += '_%s' % impl
                suffix += '_%s' % impl
                features = ['skip_test']
                defines = ['DM_LU_NULL_IMPLEMENTATION'] # if we use null implementation, then we can't test internal function

            thread_count = '1' if thread_version == 'multi' else '0'
            defines.append(f'DM_TEST_THREAD_COUNT={thread_count}')

            bld.program(features = 'cxx test'.split() + features,
                        includes = '../../../src',
                        use      = uselib + [local_lib],
                        defines  = defines,
                        exported_symbols = exported_symbols,
                        web_libs = ['library_sys.js'],
                        target   = 'test_liveupdate_job' + suffix,
                        source   = 'test_liveupdate_job.cpp')


def shutdown(ctx):
    pass
